package work.work80;

import java.util.ArrayList;
import java.util.Collections;

public class DouDiZhuGame {
    /**
     * 将54张扑克牌初始化并放在对应的集合里面
     */
    ArrayList puke = new ArrayList();
    public void init(){
        //2-10
        for (int i = 3; i < 11; i++){
            puke.add(new Puke(i +"","♠",i - 3));
            puke.add(new Puke(i +"","♥",i - 3));
            puke.add(new Puke(i +"","♣",i - 3));
            puke.add(new Puke(i +"","♦",i - 3));
        }
        //J
        puke.add(new Puke("J" +"","♠",9));
        puke.add(new Puke("J" +"","♥",9));
        puke.add(new Puke("J" +"","♣",9));
        puke.add(new Puke("J" +"","♦",9));
        //Q
        puke.add(new Puke("Q" +"","♠",10));
        puke.add(new Puke("Q" +"","♥",10));
        puke.add(new Puke("Q" +"","♣",10));
        puke.add(new Puke("Q" +"","♦",10));
        //K
        puke.add(new Puke("K" +"","♠",11));
        puke.add(new Puke("K" +"","♥",11));
        puke.add(new Puke("K" +"","♣",11));
        puke.add(new Puke("K" +"","♦",11));
        //A
        puke.add(new Puke("A" +"","♠",12));
        puke.add(new Puke("A" +"","♥",12));
        puke.add(new Puke("A" +"","♣",12));
        puke.add(new Puke("A" +"","♦",12));
        //2
        puke.add(new Puke("2" +"","♠",13));
        puke.add(new Puke("2" +"","♥",13));
        puke.add(new Puke("2" +"","♣",13));
        puke.add(new Puke("2" +"","♦",13));
        //大小王
        puke.add(new Puke("大王","🃏",14));
        puke.add(new Puke("小王","🃏",14));



        //检查牌数
//        for (Object ary : puke){
//            Puke s = (Puke) ary;
//            System.out.println(s.getPoint() + s.getType());
//        }
    }

    /**
     * 洗牌
     */
    public void xipai(){
        Collections.shuffle(puke);
//        for (Object ary : puke){
//            Puke s = (Puke) ary;
//            System.out.println(s.getPoint() + s.getType());
//        }
    }

    /**
     * 发牌
     */
    public void send(){
        System.out.println("第一人的牌：");
        Collections.sort(puke.subList(0,17),new  MySort());
        System.out.println(puke.subList(0,17));
        System.out.println("第二人的牌：");
        Collections.sort(puke.subList(17,34),new  MySort());
        System.out.println(puke.subList(17,34));
        System.out.println("第三人的牌：");
        Collections.sort(puke.subList(34,51),new  MySort());
        System.out.println(puke.subList(34,51));
        System.out.println("地主牌：");
        Collections.sort(puke.subList(51,54),new  MySort());
        System.out.println(puke.subList(51,54));
    }

    public static void main(String[] args) {
        DouDiZhuGame p = new DouDiZhuGame();
        p.init();
        p.xipai();
        p.send();
    }
}
